#include "mfs_db.h"
#include <vector>

// songs
mfs_song_list song_list_create () {
	return new mfs_song_list();
}

bool song_list_add(const mfs_song_list &sl, const song &s) {
	bool result = true;
	try {
		sl->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_song_list (mfs_song_list &sl) {
	// the elements in the vector are automatically deleted
	delete sl;
	sl = NULL;
}

// albums
mfs_album_list album_list_create () {
	return new mfs_album_list();
}

bool album_list_add (const mfs_album_list &album_list, const album &a) {
	bool result = true;
	try {
		album_list->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_album_list (mfs_album_list &album_list) {
	delete album_list;
	album_list = NULL;
}

// artists
mfs_artist_list artist_list_create () {
	return new mfs_artist_list();
}

bool artist_list_add (const mfs_artist_list &artist_list, const artist &a) {
	bool result = true;
	try {
		artist_list->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_artist_list (mfs_artist_list &artist_list) {
	delete artist_list;
	artist_list = NULL;
}

// playlists
mfs_playlist_list playlist_list_create () {
	return new mfs_playlist_list();
}

bool playlist_list_add (const mfs_playlist_list &playlist_list, const playlist &p) {
	bool result = true;
	try {
		playlist_list->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_playlist_list (mfs_playlist_list &playlist_list) {
	delete playlist_list;
	playlist_list = NULL;
}

// movies
mfs_movie_list movie_list_create () {
	return new mfs_movie_list();
}

bool movie_list_add (const mfs_movie_list &movie_list, const movie &m) {
	bool result = true;
	try {
		movie_list->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_movie_list (mfs_movie_list &movie_list) {
	delete movie_list;
	movie_list = NULL;
}

// videoclips
mfs_videoclip_list videoclip_list_create () {
	return new mfs_videoclip_list();
}

bool videoclip_list_add (const mfs_videoclip_list &videoclip_list, const videoclip &v) {
	bool result = true;
	try {
		videoclip_list->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_videoclip_list (mfs_videoclip_list &videoclip_list) {
	delete videoclip_list;
	videoclip_list = NULL;
}

// pictures
mfs_picture_list picture_list_create () {
	return new mfs_picture_list();
}

bool picture_list_add (const mfs_picture_list &picture_list, const picture &p) {
	bool result = true;
	try {
		picture_list->push_back (s);
	} catch (bad_alloc) {
		result = false;
	}
	return result;
}

void delete_picture_list (mfs_picture_list &picture_list) {
	delete picture_list;
	picture_list = NULL;
}
